package com.subnext.dao;

import static com.google.appengine.api.datastore.Query.FilterOperator.EQUAL;

import java.util.List;

import com.google.appengine.api.datastore.Query;
import com.subnext.model.CategoryEntity;
import com.subnext.model.Paging;
import com.subnext.utils.EntityCache;
import com.subnext.utils.QueryCache;

public class CategoryDao extends AbstractBaseDao<CategoryEntity>{
	
	/**
	 * @param entityCache
	 * @param queryCache
	 * @param clazz
	 */
	public CategoryDao(EntityCache entityCache, QueryCache queryCache) {
		super(entityCache, queryCache, CategoryEntity.class);
	}
	
	@Override
	protected Query newQuery() {
		Query query = super.newQuery();
		//query.addFilter("status", EQUAL, AppConstants.ENTITY_STATUS_ENABLED);
		//query.addSort("createDate", SortDirection.DESCENDING);
		return query;
	}
	
	public List<CategoryEntity> get(String type, Paging paging) {
		Query q = newQuery();
		q.addFilter("type",EQUAL, type);
		List<CategoryEntity> result = select(q, "getCategoryByType", params(type, paging.getLimit(), 
				paging.getOffset()), paging.getLimit(), paging.getOffset());
		return result;
	}
}
